package com.bdzt.beidoubox.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

import com.bdzt.beidoubox.R;
import com.bdzt.beidoubox.entity.BoxInfo;
import com.bdzt.beidoubox.utils.T;

public class AddBoxActivity extends BaseActivity {
    private EditText et_addName, et_addID;
    private BoxInfo info;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_box);
        try {
            info = (BoxInfo) getIntent().getExtras().getSerializable("info");
        } catch (Exception e){

        }
        initView();
        initData();
    }

    private void initData() {
        if (info != null) {
            et_addID.setText(info.getBoxID());
            et_addName.setText(info.getBoxName());

        }
    }

    private void initView() {
        et_addID = (EditText) findViewById(R.id.et_addID);
        et_addName = (EditText) findViewById(R.id.et_addName);
        findViewById(R.id.tv_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AddBoxActivity.this.finish();
            }
        });
    }

    public void save(View view) {
        String id = et_addID.getText().toString().trim();
        String name = et_addName.getText().toString().trim();
        if (TextUtils.isEmpty(id) || TextUtils.isEmpty(name)) {
            T.showShort(AddBoxActivity.this, "盒子名称或者ID不能为空！");
            return;
        }
    }
}
